<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>4-5</title>
  <script src='vue/vue.js'></script>
  <script src='vue/vuex.js'></script>
</head>
<!-- 
  非父子组件的传值在vue中有两种解决方案：
  1.vuex
  2.发布订阅模式（bus/总线）
 -->

<body>
  <div id="root">

  </div>
  <script>
    const app = new Vue({
      el: '#app',
      store,
      components: {
        Counter
      },
      template: `
    <div class="app">
      <counter></counter>
    </div>
  `
    })

    const Counter = {
      template: `<div>{{ count }}</div>`,
      computed: {
        count() {
          return this.$store.state.count
        }
      }
    }
  </script>
</body>

</html>